﻿<div ng-controller="orderController">
    <div class="wrapper border-bottom white-bg page-heading">
        <div class="col-lg-pull-12">
            <ol class="breadcrumb">
                <li><a href="javascript:void(0)" ng-click="goBack()">{{breadcrumb}}订单</a></li>
                <li class="active">订单详情</li>
            </ol>
        </div>
    </div>
    <div class="form-horizontal">
        <div class="row">
            <div class="col-sm-5 order_detail">
                <div class="panel panel-default">
                    <div class="panel-heading">订单信息</div>
                    <div class="panel-body">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">订单号：</label>
                            <div class="col-sm-8">
                                <p class="form-control-static">{{model.order_no}}</p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">订单类型：</label>
                            <div class="col-sm-8">
                                <p class="form-control-static">{{get_platform_text(model.platform)}}订单</p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">支付方式：</label>
                            <div class="col-sm-8">
                                <p class="form-control-static">{{model.pay_info.pay_name}}</p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">交易号：</label>
                            <div class="col-sm-8">
                                <p class="form-control-static">{{model.pay_info.pay_no}}</p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">支付流水号：</label>
                            <div class="col-sm-8">
                                <p class="form-control-static">{{model.pay_info.transaction_no}}</p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">收货地址：</label>
                            <div class="col-sm-8">
                                <p class="form-control-static">
                                    {{model.shipping.ship_to}} {{model.shipping.cell_phone}} {{model.shipping.region_name+model.shipping.address}}
                                </p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">身份证号：</label>
                            <div class="col-sm-8">
                                <p class="form-control-static">{{model.shipping.id_card}}</p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">买家留言：</label>
                            <div class="col-sm-8">
                                <p class="form-control-static">{{model.remark}}</p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label"></label>
                            <div class="col-sm-2">
                                <a ng-if="model.status !=0 && model.status != 1 && model.status != 5" class="btn btn-primary" href="javascript:void(0);" ng-click="open_refund_dialog(model)">退款</a>
                            </div>
                            <div class="col-sm-2">
                                <a ng-if="model.status == 3" class="btn btn-primary" href="javascript:void(0);" ng-click="confirmOrder(model.id)">确认收货</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-7">
                <div class="panel panel-default">
                    <div class="panel-heading">订单状态：{{get_order_status(model.status)}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;配送方式：{{get_shipping_type(model.shipping_type)}}</div>
                    <div class="panel-body">
                        <div ng-if="model.shipping_type == 1">
                            <div ng-if="model.status==5">
                                {{model.close_reason}}
                            </div>
                            <div ng-if="model.status==2 || model.status == 5">
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">选择快递物流：</label>
                                    <div class="col-sm-9">
                                        <ui-select ng-model="kdniao_selected" theme="bootstrap" on-select="kdniao_change($item, $model)">
                                            <ui-select-match placeholder="选择快递物流">{{$select.selected.text}}</ui-select-match>
                                            <ui-select-choices repeat="item in kdniao | propsFilter: {text: $select.search, value: $select.search}">
                                                <div ng-bind-html="item.text | highlight: $select.search"></div>
                                                <small>快递物流编号: {{item.value}}</small>
                                            </ui-select-choices>
                                        </ui-select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">快递物流单号：</label>
                                    <div class="col-sm-9">
                                        <input type="text" name="ship_order_number" class="form-control input-sm" ng-model="model.ship_order_number">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="col-sm-9 col-lg-offset-3">
                                        <button type="submit" ng-click="save_shipping()" class="btn btn-primary btn-sm" btn-loading="psdisabled" loading-text="保存中..." ng-disabled="psdisabled">
                                            <i class="fa fa-truck"></i> 发货
                                        </button>
                                    </div>
                                </div>
                            </div>
                            <div ng-if="model.status==3||model.status==4" class="order_detail">
                                <div class="form-group" ng-if="model.status==3">
                                    <label class="col-sm-3 control-label">收货时间：</label>
                                    <div class="col-sm-9">
                                        <p class="form-control-static">
                                            买家 <ui-countdown class="text-danger"></ui-countdown> 来确认收货,超时订单自动确认收货
                                        </p>
                                    </div>
                                </div>
                                <div ng-if="!update_type">
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">快递物流单号：</label>
                                        <div class="col-sm-9">
                                            <p class="form-control-static">{{model.shipping.ship_order_number}}</p>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">快递物流公司：</label>
                                        <div class="col-sm-9">
                                            <p class="form-control-static">{{model.shipping.express_company_name}}</p>
                                        </div>
                                    </div>
                                    <div class="form-group" ng-show="logistic_info">
                                        <label class="col-sm-3 control-label">快递跟踪：</label>
                                        <div class="col-sm-9">
                                            <p class="form-control-static" ng-if="logistic_info.success">
                                                {{logistic_info.state==2?"在途中":(logistic_info.state==3?"签收":"问题件")}}
                                                <span ng-if="logistic_info.reason">{{logistic_info.reason}}</span>
                                            </p>
                                            <div class="streamline b-l m-b" ng-if="logistic_info.success">
                                                <div class="sl-item" ng-repeat="trace in logistic_info.traces">
                                                    <div class="sl-content">
                                                        <div class="text-muted">{{trace.accept_time}}</div>
                                                        <p>{{trace.accept_station}}</p>
                                                    </div>
                                                </div>
                                            </div>
                                            <p class="form-control-static" ng-if="!logistic_info.success">没有此快递</p>
                                        </div>
                                    </div>
                                </div>
                                <div ng-if="update_type">
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">选择快递物流：</label>
                                        <div class="col-sm-9">
                                            <ui-select ng-model="kdniao_selected" theme="bootstrap" on-select="kdniao_change($item, $model)">
                                                <ui-select-match placeholder="选择快递物流">{{$select.selected.text}}</ui-select-match>
                                                <ui-select-choices repeat="item in kdniao | propsFilter: {text: $select.search, value: $select.search}">
                                                    <div ng-bind-html="item.text | highlight: $select.search"></div>
                                                    <small>快递物流编号: {{item.value}}</small>
                                                </ui-select-choices>
                                            </ui-select>
                                        </div>
                                    </div>
                                    <br />
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">快递物流单号：</label>
                                        <div class="col-sm-9">
                                            <input type="text" name="ship_order_number" class="form-control input-sm" ng-model="model.ship_order_number">
                                        </div>
                                    </div>
                                </div>
                                <br />
                                <div class="form-group">
                                    <div class="col-sm-9 col-lg-offset-3">
                                        <button type="submit" ng-click="update_shipping()" class="btn btn-primary btn-sm" btn-loading="psdisabled" ng-disabled="psdisabled" ng-if="!update_type">
                                            <i class="fa fa-truck"></i> 修改物流
                                        </button>
                                        <button type="submit" ng-click="save_shipping()" class="btn btn-primary btn-sm" btn-loading="psdisabled" loading-text="保存中..." ng-disabled="psdisabled" ng-if="update_type">
                                            <i class="fa fa-truck"></i> 保存
                                        </button>
                                    </div>
                                </div>
                            </div>

                        </div>
                        <div ng-if="model.shipping_type == 3">
                            <div ng-if="model.status==2">
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">配送人：</label>
                                    <div class="col-sm-9">
                                        <!--<ui-select ng-model="kdniao_selected" theme="bootstrap" on-select="kdniao_change($item, $model)">
                                            <ui-select-match placeholder="选择快递物流">{{$select.selected.text}}</ui-select-match>
                                            <ui-select-choices repeat="item in kdniao | propsFilter: {text: $select.search, value: $select.search}">
                                                <div ng-bind-html="item.text | highlight: $select.search"></div>
                                                <small>快递物流编号: {{item.value}}</small>
                                            </ui-select-choices>
                                        </ui-select>-->
                                        <input type="text" name="shipping_name" class="form-control input-sm" ng-model="model.shipping_name">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">电话：</label>
                                    <div class="col-sm-9">
                                        <input type="text" name="shipping_phone" class="form-control input-sm" ng-model="model.shipping_phone">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="col-sm-9 col-lg-offset-3">
                                        <button type="submit" ng-click="send_shipping()" class="btn btn-primary btn-sm" btn-loading="psdisabled" loading-text="保存中..." ng-disabled="psdisabled">
                                            <i class="fa fa-truck"></i> 送货
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <table class="table table-bordered">
            <thead>
                <tr style="background-color:#f7f7f9;">
                    <th>用户</th>
                    <th width="100">金额</th>
                    <th width="100">状态</th>
                    <th width="100">业务类型</th>
                </tr>
            </thead>
            <tbody>
                <tr ng-repeat="(index,bind) in model.binds">
                    <td>{{bind.merchant_no}}</td>
                    <td>{{bind.amount}}</td>
                    <td>{{bind.freeze?"冻结":"解冻"}}</td>
                    <td>{{bind.is_bus ? "业绩收益":"分销收益"}}</td>
                </tr>
            </tbody>
        </table>
        <table class="table table-bordered">
            <thead>
                <tr style="background-color:#f7f7f9;">
                    <th>商品</th>
                    <th width="100">单价</th>
                    <th width="100">数量</th>
                    <th width="100">优惠</th>
                    <th width="100">总价</th>
                </tr>
            </thead>
            <tbody>
                <tr ng-repeat="(index,order_item) in model.order_items">
                    <td ng-init="count=model.order_items.length">
                        <div class="media">
                            <div class="media-left">
                                <a href="{{site.share_url}}{{order_item.share_url}}" target="_blank">
                                    <img class="media-object img-thumbnail" ng-src="{{order_item.thumbnails_url|thumbnail:64:64}}">
                                </a>
                            </div>
                            <div class="media-body">
                                <p class="media-heading">{{order_item.product_name}}</p>
                                <p>{{order_item.sku_name}}</p>
                                <span>{{order_item.user_remark}}</span>
                            </div>
                        </div>
                    </td>
                    <td>
                        {{order_item.unit_price > 0 || order_item.red_drill==0 ? (order_item.unit_price | currency:'￥') :""}}
                        {{order_item.unit_price > 0 && order_item.red_drill > 0 ? " + " : ""}}
                        {{order_item.red_drill > 0 ? order_item.red_drill +"红钻" : ""}}
                    </td>
                    <td>{{order_item.quantity}} 件</td>
                    <td>
                        <span ng-if="order_item.singe_sale_type==1">限时打折：省{{order_item.singe_sale_value | currency:'￥'}}</span>
                        <span ng-if="order_item.singe_sale_type==2">限时抢购：省{{order_item.singe_sale_value | currency:'￥'}}</span>
                    </td>
                    <td width="100" rowspan="{{count}}" ng-if="index==0">
                        <p>
                            {{model.order_amount > 0 || model.red_drill == 0 ? (model.order_amount | currency:'￥') : ""}}
                            {{model.order_amount > 0 && model.red_drill > 0 ? " + " :""}}
                            {{model.red_drill > 0 ? model.red_drill +"红钻" : ""}}
                        </p>
                        <p ng-if="model.coupon_id">优惠券:{{model.coupon_amount | currency:'￥'}}</p>
                        <p ng-if="model.order_sale_amount>0">{{model.order_sale_name}}:{{model.order_amount | currency:'￥'}}</p>
                        <p ng-if="model.integral_discount>0">积分抵扣:{{model.integral_discount | currency:'￥'}}</p>
                        <p>{{model.freight==0?'包邮':'运费：'+(model.freight | currency:'￥')}}</p>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>


    <script type="text/ng-template" id="open_refund_dialog.html">
        <div class="modal-header">
            <h3 class="modal-title">退款</h3>
        </div>
        <form name="_form" class="form-horizontal w5c-form" w5c-form-validate="refund_model.validateOptions" role="form" novalidate>
            <div class="modal-body">
                <div class="form-group">
                    <label class="col-sm-3 control-label">退款类型</label>
                    <div class="col-sm-4">
                        <select name="type" class="form-control input-sm" ng-model="refund_model.type_value" required>
                            <option value="1">退货</option>
                            <option value="2">退款</option>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">退款金额</label>
                    <div class="col-sm-4">
                        <input type="text" name="amount" class="form-control input-sm" ng-model="refund_model.amount" required>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">备注</label>
                    <div class="col-sm-9">
                        <input type="text" name="remark" class="form-control input-sm" ng-model="refund_model.remark">
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button class="btn btn-primary" type="submit" w5c-form-submit="orderRefund()" btn-loading="psdisabled.save" loading-text="保存中..." ng-disabled="psdisabled.save">
                    确定
                </button>
                <button class="btn btn-primary" type="button" ng-click="cancel()">取消</button>
            </div>
        </form>
    </script>
</div>